<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改个人资料</title>

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta name="description" content="！">
<meta name="Keywords" content="">

<link rel="stylesheet" href="${contextPath}/staticwx/hx/css/reset.css">
<link rel="stylesheet" href="${contextPath}/staticwx/hx/css/global.css">
<link rel="stylesheet" href="${contextPath}/staticwx/hx/css/iconfont.css">
<link rel="stylesheet" href="${contextPath}/staticwx/hx/css/flex.css">
<link rel="stylesheet" href="${contextPath}/staticwx/hx/css/baseInfo.css">
<link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
<link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
</head>
<body style="background:#efefef">
    <div class="main-wrapper">
        <header class="header fixed">
            <div class="hl"><span class="iconfont icon-fanhui"></span></div>
            <div class="hc">修改个人资料</div>
            <div class="hr"><span class="iconfont icon-zhuye"></span></div>
        </header>

        <form class="baseForm1">
            <ul>
                <li>
                    <div class="toux" flex="cross:center main:justify" onclick="WX_FUN.chooseImage(cb_chooseImage,1);">
                        <p class="p1">头像</p>
                        <div class="img" flex="cross:center">
                            <input type="hidden" id="picbase64str_zp">
                            <#if member.headimg??>
                                <img src="${member.headimg}" alt="">
                                <#else>
                                    <img src="${contextPath}/staticwx/hx/images/hd.png" alt="">
                            </#if>
                            <span class="iconfont icon-go"></span>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="nickname" flex="cross:center main:justify">
                        <input type="text" placeholder="请输入昵称" value="${member.nickname!}">
                        <span class="iconfont icon-go"></span>
                    </div>
                </li>
            </ul>
            <br>
            <div class="mglr10">
                <button type="button" class="btnBlueBgLg" onclick="sub_b()">保存</button>
            </div>
        </form>
    </div>
<script src="${contextPath}/staticwx/hx/js/jquery-3.0.0.min.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/wxconfig.js"></script>
<script src="//cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>
<script>
    $(function() {
        //初始化微信JS接口
        WX_FUN.init('${wxJsApiSign.appid?if_exists}'
            ,'${wxJsApiSign.timestamp?if_exists}'
            ,'${wxJsApiSign.nonceStr?if_exists}'
            ,'${wxJsApiSign.signature?if_exists}');
    });
    function cb_chooseImage(localId){
        WX_FUN.showImg(localId,addImg);
        WX_FUN.uploadImage(localId,cb_uploadImage);
    }
    //动态添加img ,add by lv
    function addImg(src){
        $(".toux .img img").attr("src",src);
    }
    //上传照片到微信服务器回调函数
    function cb_uploadImage(serverId){
        $.ajax({
            type: "POST",
            url: "${contextPath}/wx/wxjs/downloadImg.htm",
            data:"wx_serverId="+serverId,
            cache:false,
            success: function(path){
                if(path){
                    if(path && path!='-1'){
                        $("#picbase64str_zp").val(path);
                    }
                }
            }
        });
    }
    function sub_b(){
        var nickname = $(".nickname input").val();
        var headimg = $("#picbase64str_zp").val();
        $.ajax({
            type: "POST",
            dataType:"json",
            url: "${contextPath}/wx/member/saveMemberInfo.htm",
            data:{nickname:nickname,headimg:headimg},
            success: function(data){
                var json = $.parseJSON(data);
                $.alert(json.errMessage,function(){
                    location.href="${contextPath}/wx/member/center.htm";
                });
            }
        });
    }
</script>
</body>
</html>